<template>
	<view>
		<baseHead title="证件信息" bg="#ffffff" color="#000000" text_right="保存" :right="true" @clickRight="clickRight">
		</baseHead>
		<view class="zhengxx">
			<view class="zhengxxnr">
				<view>企业LOGO</view>
				<view>
					<image class="imacg" :src="URL+model.LogoPath" style="border-radius: 50%;" @click="shangchuan(1)">
					</image>
				</view>
			</view>

			<view class="zhengxxnr" style="border-top:1px solid #F1F2F6">
				<view>营业执照</view>
				<view>
					<image class="imacg" :src="URL+model.LicensePath" @click="shangchuan(2)"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import baseHead from '@/pages/component/baseHead.vue'
	export default {
		data() {
			return {
				URL: this.$config.domain.staticUrl,
				model: {
					LogoPath: "",
					LicensePath: "",
				}
			}
		},
		components: {
			baseHead
		},
		onLoad() {},
		created() {
			this.listdata();
		},
		methods: {
			listdata() {
				let qyid = uni.getStorageSync('dianjiqiye');
				this.$http.core.tenantgetall(qyid.Id).then(res => {
					if (res.Success) {
						console.log(res);
						this.model = res.Result;
					}
				})
			},
			clickRight() {
				console.log(this.model)
				console.log(this.model.LogoPath);
				console.log(this.model.LicensePath);
				if (this.model.LogoPath && this.model.LicensePath) {
					//修改
					this.$http.core.tenantupdate(this.model).then(res => {
						console.log(res);
						if (res.Success) {
							this.$util.toast("修改成功")
							setTimeout(() => {
								uni.navigateBack();
							}, 1000)
						}
					})
				}else{
					this.$util.toast("请上传公司logo和营业执照")
				}

			},
			shangchuan(ite) {
				var that = this;
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					success: (res) => {
						const tempFilePaths = res.tempFilePaths //图片临时数组
						let obj = {
							src: tempFilePaths[0]
						}
						that.$util.AuploadFile(obj).then(res => {
							if (res.Success) {
								if (ite == 1) {
									that.model.LogoPath = res.Result.Path
								} else {
									that.model.LicensePath = res.Result.Path
								}
							}
						})

					}
				})
			},

		}
	}
</script>

<style>
	.zhengxx {
		background-color: #ffffff;
		margin-top: 20rpx;
	}

	.zhengxxnr {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
	}

	.imacg {
		width: 150rpx;
		height: 150rpx;
		background-color: #FFD3DB;
	}
</style>
